package com.example.demo.mapper;

import com.example.demo.domain.TeacherEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Teacher 实体类对应的持久层接口
 */
@Repository
public interface TeacherMapper {

    @Select("select * from sb_teacher")
    @Results({
            @Result(property = "id", column = "t_id"),
            @Result(property = "name", column = "t_name"),
            @Result(property = "password", column = "t_password")
    })
    List<TeacherEntity> queryList();

    @Select("select * from sb_teacher where t_id=#{id}")
    @Results({
            @Result(property = "id", column = "t_id"),
            @Result(property = "name", column = "t_name"),
            @Result(property = "password", column = "t_password")
    })
    TeacherEntity getById(int id);

    @Insert("insert into sb_teacher(t_id,t_name,t_password) values(#{id},#{name},#{password})")
    int insert(TeacherEntity entity);

    @Update("update sb_teacher set t_name=#{name} where t_id=#{id}")
    int update(TeacherEntity entity);

    @Delete("DELETE FROM sb_teacher WHERE t_id =#{id}")
    int delete(int id);

    @Delete("DELETE FROM sb_teacher WHERE t_id =#{id}")
    int deleteByEntity(TeacherEntity entity);
}
